﻿using Microsoft.Xna.Framework;
using Syngine;
using Syngine.Components;
using Syngine.Components.Screens;

namespace BenchMark
{
	public class FpsScreen : Screen
	{
		private FpsCounter _fps;

		public FpsScreen(ScreenController screenController) : base(screenController)
		{
			IsPausable = false;
			Visible = true;
		}

		public override void Initialize()
		{
			_fps = new FpsCounter("spriteFont1", new Vector2(10, 10));
			GameContext.GameController.PostDraw += GameControllerOnPostDraw;
			base.Initialize();
		}

		public override void LoadContent(LoadContext context)
		{
			_fps.LoadContent(context);
		}

		protected override void UpdateCore(UpdateContext context)
		{
			_fps.Update(context);
		}

		public override void UnloadContent()
		{
		}

		protected override void DrawCore(DrawContext context)
		{
		}

		private void GameControllerOnPostDraw(DrawContext context)
		{
			context.SpriteBatch.Begin();

			_fps.Draw(context);

			context.SpriteBatch.End();
		}
	}
}
